<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['setting']=$return['pluginset'];
	$title=$return['pluginset']['share_title']?:$return['pluginset']['title'];
	$desc=$return['pluginset']['share_desc'];
	$logo=$return['pluginset']['share_image'];
	$return['member']=cfc('core')->get_member($_SESSION['uid']);
	//公告列表
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$notice_list = pdo_getslice('jy_weishop_notice',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),array($pindex,20),$total,array('id','title','createtime'),'','id desc');
	if($notice_list){
		foreach($notice_list as &$notice){
			if($_SESSION['os']=='windows'){
				$notice['createtime']=date('m-d',$notice['createtime']);
			}else{
				$notice['createtime']=date('Y-m-d h:i',$notice['createtime']);
			}
		}
	}
	$return['notice_list']=$notice_list;
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	if($_RQ['group_id']){
		$params['group_id']=intval($_RQ['group_id']);
		$return['params']['group_id']=intval($_RQ['group_id']);
	}
	$sharelink='jy_adtext/index//fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
			'title'=>$title?:'落地宣传页',
			'desc'=>$desc?:'落地宣传页！最新公司活动动态！',
			'link'=>custom_url($sharelink,true),
			'imgUrl'=>tomedia($logo),
	);
	$return['list']=array();
	$return['pcd']=array();
	set_html('title',$title);
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	if($_RQ['title']){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$group_id=intval($_RQ['group_id']);
	if($group_id){
		$params['fenlei']=$group_id;
	}
	$ishot=intval($_RQ['ishot']);
	if($ishot){
		$params['ishot']=1;
		$return['params']['ishot']=1;
	}
	$order=intval($_RQ['order']);
	if($order==1){
		$order='id desc';
	}elseif($order==2){
		$order='ishot desc, id desc';
	}else{
		$order='readnum desc, id desc';
	}
	$fields=array('id','title','content','fenlei','keyword','createtime','readnum','re_readnum','likenum','status','desc','pic_url','yingxiao');
	$orderby=array();
	$_RQ['page'] = $_RQ['page'] ? $_RQ['page'] : 1;
	$pindex = max(1, intval($_RQ['page']));
	if(intval($_RQ['num'])){
		$psize = intval($_RQ['num']);
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('core_account_article',$params,array($pindex,$psize),$total,$fields,'',$order);
	if($list){
		foreach($list as &$item){
			$item['desc2'] = strip_tags(str_replace('&nbsp;','',$item['content']));
			$item['desc'] = $item['desc'] ? $item['desc'] : cfc('tools')->substr($item['desc2'],0,$nums);
			$item['picurl'] = $item['pic_url'] ? $item['pic_url'] : '../core/resource/images/nopic.jpg';
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['fenlei']=$fenlei[$item['fenlei']]['title'];
			$item['url']=custom_url('jy_adtext/detail//id='.$item['id'],true);
		}
	}
	$return['list']=$list?$list:array();
	exi($return);
}
?>